package com.limh.socketdemo.utils

import com.google.gson.Gson

/**
 * @function
 * @author limh
 * @date 2018/4/28 10:05
 */
object GsonUtils {
    private var gson: Gson? = null

    init {
        gson = Gson()
    }

    fun <T> str2Bean(gsonString: String, cls: Class<T>): T {
        return gson!!.fromJson(gsonString, cls)
    }

    fun bean2Str(obj: Any): String {
        return gson!!.toJson(obj)
    }
}